<?php
include 'index.php';
?>

<div id="body-wrapper">
    <div id="main-content">
        <div class="content-box">

            <?php
             include '../db/db_con.php';
          
            ?>
            <?php
            if (isset($_POST['addnews'])) {
               if ($_FILES["photo_ar"]["name"] != "") {


        if ($_FILES["photo_ar"]["type"] == "image/gif" || $_FILES["photo_ar"]["type"] == "image/jpeg" || $_FILES["photo_ar"]["type"] == "image/jpg" || $_FILES["photo_ar"]["type"] == "image/pjpeg") {

            move_uploaded_file($_FILES["photo_ar"]["tmp_name"], "img/upload/" . $_FILES["photo_ar"]["name"]);

            $img = "img/upload/" . $_FILES["photo_ar"]["name"];
        }else{
            echo 'no '.mysql_error();
        }
    
      if ($_FILES["photo_en"]["name"] != "") {


        if ($_FILES["photo_en"]["type"] == "image/gif" || $_FILES["photo_en"]["type"] == "image/jpeg" || $_FILES["photo_en"]["type"] == "image/jpg" || $_FILES["photo_en"]["type"] == "image/pjpeg") {

            move_uploaded_file($_FILES["photo_en"]["tmp_name"], "img/upload/" . $_FILES["photo_en"]["name"]);

            $img_en = "img/upload/" . $_FILES["photo_en"]["name"];
        }else{
            echo 'no '.mysql_error();
        }
    }
               }        
            

                $query = "INSERT INTO news VALUES ('','{$img_en}','{$img}')";

                if (mysql_query($query)) {

                    echo '
      <div class="notification success png_bg">
      <a href="" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
      <div>
	    This New Added Is Done ..
	</div>
      </div>';
                } else {
                    echo '
      <div class="notification error png_bg">
	<a href="" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
	   <div>
	     This New Added Is not Done ..
	   </div>
       </div>';
                }
            }
            ?>

            <div class="content-box-header" id = "addProducts" >

                <h3><?= Add_News ?></h3>

                <div class="clear"></div>

            </div>

            <div class="content-box-content">
                <div class="tab-content default-tab" id="tab2">

                    <form action="AddNews.php?type=News&lang=<?= $lang ?>" method="post" name = "addnews" enctype="multipart/form-data">

                        <fieldset>

                            <p>
                                <label><?= News_Photo_ar ?></label>
                                <input class="text-input small-input" type="file" id="small-input" name="photo_ar" />
                            </p>

                            <p>
                                <label><?= News_Photo_en ?></label>
                                <input class="text-input small-input" type="file" id="small-input" name="photo_en" />
                            </p>

                          

                            <p>
                                <input class="button" type="submit" name = "addnews" value="<?=Add_News?>" />
                            </p>

                        </fieldset>

                        <div class="clear"></div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div> 